﻿using System.Windows.Controls;
using VisualStock.Modules.StockMarket.HistoricalData.Interfaces;
using System.Windows;

namespace VisualStock.Modules.StockMarket.HistoricalData
{
    public partial class HistoricalDataCompositeView : UserControl, IHistoricalDataCompositeView
    {
        public HistoricalDataCompositeView()
        {
            InitializeComponent();

            (Application.Current.RootVisual as UserControl).SizeChanged += new SizeChangedEventHandler(RootVisual_SizeChanged);
        }

        public void RootVisual_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            LayoutRoot.Height = e.NewSize.Height > 600 ? e.NewSize.Height - 20 : 580;
        }

        public void SetModel(IHistoricalDataCompositeViewModel model)
        {
            this.DataContext = model;
        }
    }
}
